import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ConfigQuery, ConfigPage, ConfigForm } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getConfigPage(
  queryParams: ConfigQuery
): AxiosPromise<PageResult<ConfigPage[]>> {
  return request({
    url: "/config/config/index",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getConfigForm(ids: string): AxiosPromise<ConfigForm> {
  return request({
    url: "/config/config/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addConfig(data: any) {
  return request({
    url: "/config/config/add",
    method: "post",
    data: data,
  });
}

export function releaseConfig(data: any) {
  return request({
    url: "/config/config/release",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateConfig(data: ConfigForm) {
  return request({
    url: "/config/config/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteConfig(data: any) {
  return request({
    url: "/config/config/del",
    method: "delete",
    data,
  });
}
